package com.dq.domain.sys.user.center;

import com.dq.domain.base.BaseEntity;
import com.dq.domain.subscribe.Subscribe;
import com.dq.domain.sys.user.Account;
import com.dq.domain.sys.user.user.BossUser;
import com.dq.vo.baseVo.VO;
import com.dq.domain.orders.Orders;
import com.dq.domain.orders.UserOrder;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.domain.sys.user.user.WxUser;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;

/***
 * @author cf
 */
@Data
@Entity
@ApiModel("销售单销售员工关联表")
public class UserAccountStaffUser extends BaseEntity implements VO.ToVO {

    @ManyToOne
    @ApiModelProperty("充值记录")
    private Account account;

    @ManyToOne
    @ApiModelProperty("员工")
    private BossUser staffUser;

    @ApiModelProperty("占比")
    private BigDecimal proportion;

    @ApiModelProperty("员工提成")
    private BigDecimal achievements;



    @Data
    @ApiModel(value = "视图")
    public static class Vo implements VO {
//        @ApiModelProperty("")
        protected Long id;
        protected String accountChangeTypeEn;
        protected String accountChangeTypeCn;
        @ApiModelProperty("account里面的金额")
        protected BigDecimal price;
        protected Long staffUserId;
        protected Long orgId;
        protected String orgName;
        protected String staffUserRealcName;
        @ApiModelProperty("占比")
        private BigDecimal proportion;
        @ApiModelProperty("员工提成")
        protected BigDecimal achievements;
        protected String createTime;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.getId();
        vo.accountChangeTypeCn = this.getAccount()!= null && this.getAccount().getAccountChangeType() != null ? this.getAccount().getAccountChangeType().name:"";
        vo.accountChangeTypeEn = this.getAccount()!= null && this.getAccount().getAccountChangeType() != null ? this.getAccount().getAccountChangeType().toString():"";
        vo.price = this.getAccount()!= null ? this.getAccount().getPrice() : BigDecimal.ZERO;
        vo.staffUserId = this.getStaffUser() != null ? this.getStaffUser().getId() : null;
        vo.staffUserRealcName = this.getStaffUser() != null ? this.getStaffUser().getUserRealcName() : "";
        vo.orgId = this.getAccount()!= null && this.getAccount().getSysDept()!= null ? this.getAccount().getSysDept().getId() : null;
        vo.orgName = this.getAccount()!= null && this.getAccount().getSysDept()!= null ? this.getAccount().getSysDept().getSimpleName() : "";
        vo.proportion = this.getProportion();
        vo.achievements = this.getAchievements();
        vo.createTime = fmt(this.getCreateTime(),TimeUtil.YYYY_MM_DD_HH_MM_SS);
        return vo;
    }

    @Data
    @ApiModel("技师销售订单")
    public static class StaffOrderListVo{
        @ApiModelProperty("订单id")
        protected Long orderId;
        @ApiModelProperty("用户真实姓名")
        protected String userRealcName;
        @ApiModelProperty("用户等级")
        protected String level;
        @ApiModelProperty("商品名")
        protected String goodsName;
        @ApiModelProperty("订单金额")
        protected BigDecimal orderPrice;
        @ApiModelProperty("积分余额")
        protected Long integralBalance;
        @ApiModelProperty("创建时间")
        protected String createTime;
    }

    public StaffOrderListVo toStaffOrderListVo(){
        StaffOrderListVo vo = new StaffOrderListVo();
        return vo;
    }
}
